package com.ztf.health;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

@Component
public class MyHealthIndicator implements HealthIndicator {

    @Override
    public Health health() {
        Boolean errorCode = check(); // perform some specific health check
        if (errorCode) {
            return Health.down().withDetail("Error Code", errorCode).build();
        }
        return Health.up().build();
    }

    // 自己去连接mongdb 如果连不上说明状态down
    // 根据自己项目的业务需求定制
    private boolean check() {
        // TODO: 验证逻辑
        int a=1/1;
        return true;
    }
}
